//
//  VideoTableViewCell.m
//  Menu
//
//  Created by dllo on 15/7/1.
//  Copyright (c) 2015年 lijiangang. All rights reserved.
//

#import "VideoTableViewCell.h"

@implementation VideoTableViewCell

- (void)dealloc
{
    [_videoIMGview release];
    [_videoTitleLabel release];
    [super dealloc];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self createSubViews];
    }
    return self;
}

-(void)createSubViews
{
    self.videoIMGview = [[UIImageView alloc] initWithFrame:CGRectMake(5*WIDTH, 5*HEIGHT, 130*WIDTH, 110*HEIGHT)];
    UIImageView *playImgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"play_button.png"]];
    playImgV.center = self.videoIMGview.center;
    [self.videoIMGview addSubview:playImgV];
    [self.contentView addSubview:self.videoIMGview];
    [playImgV release];
    [_videoIMGview release];
    
    self.videoTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.videoIMGview.frame.origin.x + self.videoIMGview.frame.size.width, 45*HEIGHT, 220*WIDTH, 30*HEIGHT)];
    self.videoTitleLabel.backgroundColor = [UIColor clearColor];
    self.videoTitleLabel.textAlignment = NSTextAlignmentRight;
    self.videoTitleLabel.font = [UIFont systemFontOfSize:18*WIDTH];
    [self.contentView addSubview:self.videoTitleLabel];
    [_videoTitleLabel release];
}

-(void)setVideoModel:(VideoModel *)videoModel
{
    if (_videoModel != videoModel)
    {
        [_videoModel release];
        _videoModel = [videoModel retain];
    }
    
    self.videoTitleLabel.text = videoModel.title;
    NSURL *url = [NSURL URLWithString:videoModel.previewImage];
    [self.videoIMGview sd_setImageWithURL:url];
    
}









































- (void)awakeFromNib
{
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
